package com.hntest.service.impl;

import com.hntest.dao.MoneyWithDrawDao;
import com.hntest.entity.Moneywithdraw;
import com.hntest.entity.Pager;
import com.hntest.service.MoneyWithDrawService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("MoneyWithDrawService")
public class MoneyWithDrawServiceImpl implements MoneyWithDrawService {

    @Autowired
    private MoneyWithDrawDao moneyWithDrawDao;

    @Override
    public int getCounts(Moneywithdraw moneywithdraw) {
        return moneyWithDrawDao.getCounts(moneywithdraw);
    }

    @Override
    public List<Moneywithdraw> getListByPage(Pager pager, Moneywithdraw moneywithdraw) {
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("moneywithdraw",moneywithdraw);
        map.put("pageStart",1);
        map.put("pageEnd",10000);
        int n = moneyWithDrawDao.getListByPage(map).size();
        pager.setTotalCounts(n);
        map.put("pageStart",(pager.getCurrPage()-1)*pager.getPageSize()+1);
        map.put("pageEnd",pager.getCurrPage()*pager.getPageSize());
        List<Moneywithdraw> list= moneyWithDrawDao.getListByPage(map);
        return list;
    }

    @Override
    public int DrawMoney(Moneywithdraw draw) {
        System.out.println("正在提现");
        return moneyWithDrawDao.DrawMoney(draw);
    }
}
